package profile.data;

import java.util.ArrayList;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class RaportProfile {
	
	int startSize;
	
	public void runTests(ArrayList<String> codeInjection, int codeInjectionSize) {
		ArrayList<String> webElements = new ArrayList<String>();
		webElements.add("email");
		webElements.add("password");
		profileRaportProfileTest(codeInjection, codeInjectionSize, webElements);
	}
	
	private void profileRaportProfileTest(ArrayList<String> codeInjection,
			int codeInjectionSize, ArrayList<String> webElements)  {
		WebDriver driver = new FirefoxDriver();
		driver.get("https://www.snapsation.com/login/");
		WebElement email = driver.findElement(By.name(webElements.get(0)));
		email.sendKeys("damciodamcio666@gmail.com");
		WebElement password = driver.findElement(By.name(webElements.get(1)));
		password.sendKeys("admin123admin");
		email.submit();
		
		driver.get("https://www.snapsation.com/offer/show/51b399400e8ef5fe14483282");
		
		for(startSize = 1; startSize < codeInjectionSize; startSize++){
			WebElement raportLink = driver.findElement(By.xpath("(//div[7]/a)"));
			raportLink.click();
			WebElement raportField = driver.findElement(By.xpath("(//div[2]/textarea)"));
			raportField.sendKeys(codeInjection.get(startSize));
			raportField.submit();
		}
		
	}
}
